import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import p02 from './p02';
import render from '@feidao/web/atom/browser/render/render';
import get_form_data from '@feidao/web/atom/browser/form/get-data';

export default async function a014(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	fd.data.node.querySelector<HTMLTextAreaElement>('[data-feidao-id="fd-w000008-005"]').innerHTML = '';

	// 获取属性，渲染p02
	const widgets = fd.data.node.querySelector<HTMLFormElement>('[name="widgets"]');
	const data = get_form_data(widgets);
	let attrs = '';
	for (const attr in data) {
		if (data.hasOwnProperty(attr)) {
			const v = data[attr];
			if (v === true) {
				attrs += attr + ' ';
			} else {
				if (v) {
					attrs += attr + '=\'' + v + '\' ';
				}
			}
		}
	}
	render(fd, attrs, p02, 'p02', 'inner');

	const a = fd.data.node.querySelector<HTMLAreaElement>('[data-feidao-id="fd-w000008-002"]');
	a.innerHTML = `
	<fd-w000008 data-feidao-id="fd-w000008-001" style="width:40em;height:15em;display:block;position: absolute;" ${attrs}>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="1" is-before="true"
	  slot="time">
	  现在
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="10" is-before="true"
	  slot="time">
	  之前10分钟
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="50" is-before="true"
	  slot="time">
	  之前50分钟
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="50" is-before="false"
	  slot="time">
	  之后50分钟
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="300" is-before="false"
	  slot="time">
	  之后300分钟
	</div>
	<div slot="btn-sure" style="width: 10em;height: 3em;background: lightgoldenrodyellow;display: block;line-height: 3em;text-align: center;">确定</div>
	<div slot="btn-cancle" style="width: 10em;height: 3em;background: lightgoldenrodyellow;display: block;line-height: 3em;text-align: center;">取消</div>
  </fd-w000008>
	`;

}
